#include "randomjunk.h"

#define JUNK_COUNT 60

extern u8 junk_vent_png[];
extern u8 junk_poster_png[];
extern u8 junk_rip_png[];
extern u8 junk_heart_png[];
extern u8 junk_watch_png[];

extern u8 junk_sign1_png[];
extern u8 junk_sign2_png[];
extern u8 junk_sign3_png[];
extern u8 junk_sign4_png[];
extern u8 junk_sign5_png[];
extern u8 junk_sign6_png[];

RandomJunk::RandomJunk()
{
	_junkImages.push_back(new Image());
   if(_junkImages[0]->LoadImage(junk_vent_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
   
   	_junkImages.push_back(new Image());
   if(_junkImages[1]->LoadImage(junk_poster_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  
  	_junkImages.push_back(new Image());
   if(_junkImages[2]->LoadImage(junk_rip_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  
  	_junkImages.push_back(new Image());
   if(_junkImages[3]->LoadImage(junk_heart_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  
  	_junkImages.push_back(new Image());
   if(_junkImages[4]->LoadImage(junk_watch_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  
  	_junkImages.push_back(new Image());
   if(_junkImages[5]->LoadImage(junk_sign1_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  
  	_junkImages.push_back(new Image());
   if(_junkImages[6]->LoadImage(junk_sign2_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  /*
  	_junkImages.push_back(new Image());
   if(_junkImages[7]->LoadImage(junk_sign3_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  
  	_junkImages.push_back(new Image());
   if(_junkImages[8]->LoadImage(junk_sign4_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
  
  	_junkImages.push_back(new Image());
   if(_junkImages[9]->LoadImage(junk_sign5_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
   
  	_junkImages.push_back(new Image());
   if(_junkImages[10]->LoadImage(junk_sign6_png, IMG_LOAD_TYPE_BUFFER)!= IMG_LOAD_ERROR_NONE)exit(0);
   */
   
   for(int i = 0; i < JUNK_COUNT; i++)
   {
		_junkList.push_back(new Sprite());
		
		//Get Random Junk Image
		int r = rand() % _junkImages.size();
		int x = (rand() % WORLD_WIDTH) - (WORLD_WIDTH/2.0);
		int y = (rand() % WORLD_HEIGHT) - (WORLD_HEIGHT/2.0);
		
		_junkList[i]->SetImage(_junkImages[r]);
		_junkList[i]->SetPosition(x, y);
	}
	
}

RandomJunk::~RandomJunk()
{

}

void RandomJunk::Render(float dx, float dy)
{
   for(int i = 0; i < JUNK_COUNT; i++)
   {
		_junkList[i]->Draw(dx, dy);
	}
}
